home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 5 / The 640 Meg Shareware Studio CD-ROM Volume V (Data Express)(1994).ISO / amiga / tdemo2.lha / ProgrammersInfo / UserStatus.mod.c < prev   
C/C++ Source or Header  |  1994-06-05  |  10KB  |  281 lines

  1. /*                          UserStatus.mod
  2.  
  3. .----------------------------------------.------------------------------------.
  4. | Handle:                                |   Slot Number: 1,222               |
  5. |   From: 123456789012345678901234567890 | Computer Type:                     |
  6. |  Phone:                                |     Last Call: 06/06/93 @ 22:22:22 |
  7. |-------------------------.--------------^----------.-------------------------|
  8. | Security Level: 233     | Daily Time: 1,000       | Bulletins Access: Yes   |
  9. |     Byte Ratio:         |  Time Left: 1,000       |      Door Access:       |
  10. |     File Ratio: Off     |  Time Bank: 1,000       |      File Access:       |
  11. `-------------------------^-------------------------^-------------------------'
  12.  
  13.          Totals                   Today's Stats               Limits
  14. .-------------------------.-------------------------.-------------------------.
  15. |    Calls: 11,000        |    Calls: 11,000        |    Calls: 11,000        |
  16. | Messages: 11,000        | Messages: 11,000        | Messages: 22,099        |
  17. |-------------------------|-------------------------|-------------------------|
  18. | UL Files: 1,000         | UL Files: 1,000         |                         |
  19. | UL Bytes: 1,000,000,000 | UL Bytes: 1,000,000,000 |                         |
  20. |-------------------------|-------------------------|-------------------------|
  21. | DL Files: 1,000         | DL Files: 1,000         | DL Files: 1,000         |
  22. | DL Bytes: 1,000,000,000 | DL Bytes: 1,000,000,000 | DL Bytes: 1,000,000,000 |
  23. `-------------------------^-------------------------^-------------------------'
  24. */
  25. //**********************
  26. //*****  Includes  *****
  27. //**********************
  28.  
  29. #include <proto/all.h>
  30. #include <stdio.h>
  31. #include <stdlib.h>
  32. #include <time.h>
  33.  
  34. #include <stdarg.h>
  35. #include <string.h>
  36. #include <tempest/headers.h>
  37. #include <Skeleton/Commas.h>
  38.  
  39. //********************************
  40. //*****  Structures/Defines  *****
  41. //********************************
  42.  
  43.  struct MyMessage
  44.   {
  45.    struct Message Msg; // for Exec message routines
  46.    ULONG  Command;     // Command to be executed.
  47.  
  48.    char   *text1,
  49.           *text2,
  50.           *text3;
  51.    int    Value1,
  52.           Value2;
  53.    ULONG  LongValue;
  54.    LONGBITS Flags;
  55.    int    carrier;
  56.    struct User       *User;
  57.    struct SystemData *SystemData;
  58.    struct NodeData   *NodeData;
  59.    struct Today      *Today;
  60.   };
  61.  
  62. struct MyMessage send;
  63.  
  64. struct User *User;
  65. struct MsgPort *MyPort = NULL;
  66. struct MyMessage *msg;
  67.  
  68. int  DoorStart(TEXT *);
  69. int  DOORIO(VOID);
  70. VOID CloseStuff(VOID);
  71. VOID pl(TEXT *,...);
  72. VOID GetStr(TEXT *,int);
  73.  
  74. char MyName[60],st[60];
  75.  
  76. //******************
  77. //*****  Main  *****
  78. //******************
  79.  
  80. main(int argc,char *argv[])
  81. {
  82.  char string[200],string1[200];
  83.  char Day[5],Month[5],Year[5];
  84.  register int x=1;
  85.  if(!DoorStart(argv[1])) { PutStr("UserStatus.mod v3.15\n"); exit(0); }
  86. //********************************************************************
  87.  
  88.  pl("\f.----------------------------------------.------------------------------------.\r\n");
  89.  pl("| Handle%-30s |   Slot Number: %-5s               |\r\n",
  90.      User->Name,commas(User->Slot_Number,buff));
  91.  pl("|   From: %-30s Computer Type: %11s         |\r\n",
  92.      User->City,User->ComputerType);
  93.  pl("|  Phone: %-12s                   |     Last Call:                     |\r\n",
  94.      User->VoicePhone);
  95.  pl("|-------------------------.--------------^----------.-------------------------|\r\n");
  96.  pl("| Security Level: %3d     Daily Time: %-5s       Bulletins Access:       |\r\n",
  97.      User->Security,commas((User->Limit_Time),buff));
  98.  pl("|     Byte Ratio: %-2d      |  Time Left: %-5s       |      Door Access:       |\r\n",
  99.      User->F_Ratio,commas(User->Left_Time,buff));
  100.  
  101.  pl("|     File Ratio: %-2d      |  Time Bank: %-5s       |      File Access:       |\r\n",
  102.      User->B_Ratio,commas((User->Total_TimeBank),buff));
  103.  pl("`-------------------------^-------------------------^-------------------------'\r\n\r\n");
  104.  
  105.  pl("         Totals                   Today's Stats               Limits\r\n");
  106.  pl(".-------------------------.-------------------------.-------------------------.\r\n");
  107.  pl("|    Calls: %-6s        |    Calls: ",
  108.      commas(User->Total_Calls,buff));
  109.  pl("%-6s        |    Calls: ",
  110.      commas(User->Period_Calls,buff));
  111.  pl("%-6s        |\r\n",commas(User->Limit_Calls,buff));
  112.  
  113.  
  114.  pl("| Messages: %-6s        Messages: ",
  115.      commas(User->Total_Posts,buff));
  116.  pl("%-6s        Messages: ",
  117.      commas(User->Period_Posts,buff));
  118.  pl("%-6s        |\r\n",commas(User->Limit_Posts,buff));
  119.  
  120.  pl("|-------------------------|-------------------------|-------------------------|\r\n");
  121.  pl("| UL Files: %-6s        UL Files: ",
  122.      commas(User->Total_ULFiles,buff));
  123.  pl("%-6s        |                         |\r\n",commas(User->Period_ULFiles,buff));
  124.  
  125.  
  126.  pl("| UL Bytes: %-13s UL Bytes: ",
  127.      commas(User->Total_ULBytes,buff));
  128.  pl("%-13s |                         |\r\n",commas(User->Period_ULBytes,buff));
  129.  
  130.  pl("|-------------------------|-------------------------|-------------------------|\r\n");
  131.  pl("| DL Files: %-6s        DL Files: ",
  132.      commas(User->Total_DLFiles,buff));
  133.  pl("%-5s         DL Files: ",
  134.      commas(User->Period_DLFiles,buff));
  135.  pl("%-5s         |\r\n",commas(User->Limit_DLFiles,buff));
  136.  
  137.  pl("| DL Bytes: %-13s DL Bytes: ",
  138.      commas(User->Total_DLBytes,buff));
  139.  pl("%-13s DL Bytes: ",
  140.      commas(User->Period_DLBytes,buff));
  141.  pl("%-13s |\r\n",commas(User->Limit_DLBytes,buff));
  142.  pl("`-------------------------^-------------------------^-------------------------'\r\n");
  143.  
  144.  
  145. // strcpy(string,ctime(&User->Time_Last_Logoff));
  146. // strmid(string,Month,5,3);
  147. // strmid(string,Day,9,2);
  148. // strmid(string,Year,23,2);
  149. // pl("Lst Date On : %2s %s %s\r\n",Day,Month,Year);
  150. //********************************************************************
  151. // pl("Security Lv : %d\r\n",User->Security);
  152. //********************************************************************
  153. // pl("# Times On  : %-5d       Today : %d\r\n",User->Total_Calls,User->Period_Calls);
  154. //********************************************************************
  155. // pl("Msgs Posted : %-5d       Today : %d\r\n",User->Total_Posts,User->Period_Posts);
  156. //********************************************************************
  157. // if(User->F_Ratio==0) strcpy(string1,"Disabled");
  158. // else                sprintf(string1,"%d/1",User->B_Ratio);
  159. // pl("File Ratio  : %s\r\n",string1);
  160. //********************************************************************
  161. // if(User->B_Ratio==0) strcpy(string1,"Disabled");
  162. // else                sprintf(string1,"%d/1",User->B_Ratio);
  163. // pl("Byte Ratio  : %s\r\n",string1);
  164. //********************************************************************
  165. // pl("# Downloads : %-4d        Today : %d\r\n",User->Total_DLFiles,User->Period_DLFiles);
  166. //********************************************************************
  167. // pl("# Uploads   : %-4d        Today : %d\r\n",User->Total_ULFiles,User->Period_ULFiles);
  168. //********************************************************************
  169. // pl("Bytes DL'd  : %-10ld  Today : %ld \r\n",User->Total_DLBytes,User->Period_DLBytes);
  170. //********************************************************************
  171. // pl("Bytes UL'd  : %-10ld  Today : %ld\r\n",User->Total_ULBytes,User->Period_ULBytes);
  172. //********************************************************************
  173. // GetStr(string1,19);
  174. // pl("Online Baud : %s\r\n",string1);
  175. //********************************************************************
  176. // pl("Bytes Avail : %ld\r\n\r\n",User->Limit_DLBytes);
  177. //********************************************************************
  178.  
  179. //*************************
  180. //*****  Close Stuff  *****
  181. //*************************
  182.  CloseStuff();
  183. }
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193. //************************
  194. //*****  Door Start  ***** // MUST BE INCLUDED IN ALL DOORS!
  195. //************************
  196.  
  197. int DoorStart(TEXT *node)
  198. {
  199.  struct MsgPort *HisPort;
  200.  send.carrier=0;
  201.  sprintf(st,"%s:TEMPEST_DOOR",node);
  202.  HisPort = FindPort(st);
  203.  if(HisPort==NULL) return (FALSE);
  204.  sprintf(MyName,"%s:DOOR_PORT",node);
  205.  MyPort = CreatePort(MyName,0L);
  206.  if(MyPort==NULL)
  207.   {
  208.    PutStr("Cant open port");
  209.    return(int)FALSE;
  210.   }
  211.  DOORIO();
  212.  User=*&send.User;
  213.  return (int)TRUE;
  214. }
  215.  
  216. //********************
  217. //*****  DoorIO  ***** // MUST BE INCLUDED IN ALL DOORS!
  218. //********************
  219.  
  220. int DOORIO(VOID)
  221. {
  222.  struct MsgPort *HisPort;
  223.  if(send.carrier) return(0);
  224.  HisPort = FindPort(st);
  225.  if(HisPort!=NULL)
  226.   {
  227.    send.Msg.mn_Node.ln_Type = NT_MESSAGE;
  228.    send.Msg.mn_Length = sizeof(send);
  229.    send.Msg.mn_ReplyPort = MyPort;
  230.    send.carrier=0;
  231.    PutMsg((struct MsgPort *)HisPort,(struct Message *)&send);
  232.    Wait(1 << MyPort->mp_SigBit);
  233.    GetMsg(MyPort);
  234.    if(send.carrier) CloseStuff();
  235.    return(1);
  236.   }
  237.  return(0);
  238. }
  239.  
  240. //*************************
  241. //*****  Close Stuff  ***** // MUST BE INCLUDED IN ALL DOORS!
  242. //*************************
  243.  
  244. VOID CloseStuff(VOID)
  245. {
  246.  send.Command=999;
  247.  DOORIO();
  248.  while(msg=(struct MyMessage *)GetMsg(MyPort)) ReplyMsg((struct Message *)msg);
  249.  if(MyPort) DeletePort(MyPort);
  250.  exit(0);
  251. }
  252.  
  253. //*********************************
  254. //*****  GetStr (Get String)  ***** // Command 33
  255. //*********************************
  256.  
  257. VOID GetStr(TEXT *s,int opt)
  258. {
  259.  send.Command=33;
  260.  send.Value1=opt;
  261.  strcpy(s,NULL);
  262.  send.text1=s;
  263.  DOORIO();
  264. }
  265.  
  266. //*****************************
  267. //*****  PL (Print Line)  ***** // Command 1 with a twist
  268. //*****************************
  269.  
  270. VOID pl(TEXT *fmt,...)
  271. {
  272.  va_list args;
  273.  char s[255];
  274.  va_start(args,fmt);
  275.  vsprintf(s,fmt,args);
  276.  va_end(args);
  277.  send.Command=1;
  278.  send.text1=&s[0];
  279.  DOORIO();
  280. }
  281.